package com.sinoglobal.dumping.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;

import com.sinoglobal.dumping.R;
import com.sinoglobal.dumping.base.Dumpling_ShareAbstractActivity;

public class Dumpling_SendCardCompleteActivity extends Dumpling_ShareAbstractActivity {


    private Button sendAgain;
    private Button share;
    private String shareContent;
    private String shareTitle;
    private String shareUrl;
    private String sharePicUrl;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dumpling_activity_send_card_complete);
        initView();
        initShareData();
    }

    private void initShareData() {
        shareContent = getIntent().getStringExtra("shareContent");
        shareTitle = getIntent().getStringExtra("shareTitle");
        shareUrl = getIntent().getStringExtra("shareUrl");
        sharePicUrl = getIntent().getStringExtra("sharePicUrl");
    }

    private void initView() {
        mTemplateTitleText.setText("包饺子");
        View viewShare = getView(R.id.title_right_btn_share);
        hideViewForGone(viewShare, mTemplateRightImg);
        sendAgain = (Button) findViewById(R.id.dumpling_card_complete_again);
        share = (Button) findViewById(R.id.dumpling_card_complete_share);
        sendAgain.setOnClickListener(this);
        share.setOnClickListener(this);
        mTemplateLeftImg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                goIntent(Dumpling_MainActivity.class);
            }
        });
    }

    @Override
    public void onAntiViolence(View view) {
        if (R.id.dumpling_card_complete_again==view.getId()) {
            Intent mIntent = new Intent();
            mIntent.putExtra("sendType", 2);
            mIntent.setClass(Dumpling_SendCardCompleteActivity.this, Dumpling_CongratulationCardActivity.class);
            startActivity(mIntent);
        } else if(R.id.dumpling_card_complete_share==view.getId()){
            setShare(shareContent, shareTitle, null, shareUrl, 0, sharePicUrl);
        }
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            goIntent(Dumpling_MainActivity.class);
        }
        return super.onKeyDown(keyCode, event);
    }
}
